home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / FILE / Binbit.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.3 KB  |  57 lines

  1. // Dynamic link library implementation of NeuroSolutions File component in Binary mode
  2.  
  3. #include "NSDLL.h" 
  4. #include <stdio.h> 
  5.  
  6. unsigned char    typedSample,
  7.         Nread,
  8.         bitCount = 8;
  9.  
  10. /******************************/
  11. /* Read next sample from file */
  12. __declspec(dllexport) BOOL performFile(
  13.     DLLData        *instance,    // Pointer to instance data (may be NULL)
  14.     FILE        *file,         // Pointer to the opened file
  15.     NSFloat        *sample        // Location to place next sample
  16.     )
  17. {
  18.  
  19.     if (bitCount==8) {
  20.         Nread = fread(&typedSample, sizeof(unsigned char), 1, (FILE*)file);
  21.         bitCount=0;
  22.         }
  23.     if (Nread==1) {
  24.         *sample = (NSFloat)(1 & (typedSample>>(7-bitCount++)));
  25.         return TRUE;
  26.         }
  27.     else    {
  28.         fclose((FILE*)file);
  29.         bitCount = 8;
  30.         return FALSE;
  31.         }
  32. }
  33.  
  34. /********************************************/
  35. /* Open and the file and return its pointer */
  36. __declspec(dllexport) FILE *openFile(DLLData *instance, const char *filePath)
  37. {
  38.     return fopen(filePath, "rb");
  39. }
  40.  
  41. /******************************************/
  42. /* Management of instance data (OPTIONAL) */
  43. /*
  44. __declspec(dllexport) DLLData *allocFile(
  45.     DLLData    *oldInstance    // Pointer to the last instance if reallocating
  46.     )
  47. {
  48.     DLLData *instance = NULL;
  49.     return instance;
  50. }
  51.  
  52. __declspec(dllexport) void freeFile(DLLData *instance)
  53. {
  54.     freeDLLInstance(instance);
  55. }
  56. */
  57.